package com.ydw.scheduled;

import org.springframework.context.annotation.AnnotationConfigApplicationContext;
import org.springframework.scheduling.config.ScheduledTaskRegistrar;

import java.util.concurrent.Executors;
import java.util.concurrent.ScheduledExecutorService;

/**
 * @author HYL
 * @create 2017-07-07 上午9:26
 **/

public class ScheduledConfig_Threads  {

    public ScheduledTaskRegistrar setScheduledTaskRegistrar(ScheduledTaskRegistrar taskRegistrar){
        ScheduledExecutorService taskPool = Executors.newScheduledThreadPool(100);//默认线程池的大小是100个
        taskRegistrar.setScheduler(taskPool);
        return taskRegistrar;
    }

    public static void main(String[] args) {
        AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext(ScheduledConfig.class);
    }
}
